<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<html>
<head>
    <title>Send message</title>
    <script type="text/javascript" src="/voteup/resources/js/jquery-1.6.1.js"></script>
    <script type="text/javascript" src="/voteup/resources/js/stylescript.js"></script>
</head>
<body>
<c:import url="/WEB-INF/jsp/header.jsp"/>
<c:import url="/WEB-INF/jsp/menu.jsp"/>
<p>
<table class="answer" cellspacing="15px">
    <tr>
        <td colspan="3">
            <h3><c:if test="${(type eq null) or (!type eq 'sent')}">Your answer:</c:if>
                <c:if test="${type eq 'sent'}">Your adding:</c:if><br></h3>
            <form:form commandName="message" method="POST" action="/voteup/messages/sendnewmessage">
                <p><input type="hidden" name="to"
                          <c:if test="${(type eq null) or (!type eq 'sent')}">value="${recievedmessage.fromPerson.personId}"/></c:if>
                    <c:if test="${type eq 'sent'}">value="${recievedmessage.toPerson.personId}"/></c:if>
                </p>

                <p><form:hidden path="title"/></p>

                <p><form:textarea path="body" cssClass="inputtext" wrap="hard" cols="50" rows="10"
                                  maxlength="2000"/></p>
                <input type="submit" class="inputbutton" value="Send message"/>
            </form:form>
        </td>
    </tr>
    <tr>
        <td>
            <a
                    <c:if test="${(type eq null) or (!type eq 'sent')}">href="/voteup/persons/${recievedmessage.fromPerson.personId}"</c:if>
                    <c:if test="${type eq 'sent'}">href="/voteup/persons/${recievedmessage.toPerson.personId}"</c:if>>
                <p align="center"><img
                        <c:if test="${(type eq null) or !(type eq 'sent')}">src="/voteup/resources/img/avatars/${recievedmessage.fromPerson.avatar}.jpg"</c:if>
                        <c:if test="${type eq 'sent'}">src="/voteup/resources/img/avatars/${recievedmessage.toPerson.avatar}.jpg"</c:if>
                        width="60"
                        height="80"
                        border="0"><br>
                    <c:if test="${(type eq null) or (!type eq 'sent')}">${recievedmessage.fromPerson.lastName} ${recievedmessage.fromPerson.firstName}</c:if>
                    <c:if test="${type eq 'sent'}">${recievedmessage.toPerson.lastName} ${recievedmessage.toPerson.firstName}</c:if>
                </p></a>
        </td>
        <td>
        <td align="left" valign="middle">
            <c:if test="${type eq 'sent'}">You wrote:</c:if>
            <p> ${recievedmessage.date} ${recievedmessage.time}<br>
                Title: ${recievedmessage.title}<br>
                Message: ${recievedmessage.body}</p>
        </td>
    </tr>

</table>
</body>
</html>